package com.icehand.demo.handler;

import com.alibaba.otter.canal.protocol.CanalEntry;
import com.icehand.canal.annotation.DeleteHandlePoint;
import com.icehand.canal.annotation.HandlePoint;
import com.icehand.canal.annotation.InsertHandlePoint;
import com.icehand.canal.annotation.UpdateHandlePoint;

/**
 * @author icehand
 */
@HandlePoint
public class PointAnnHandlerDemo {
    @InsertHandlePoint
    public void handle(CanalEntry.EventType eventType, CanalEntry.RowData rowData) {
        rowData.getAfterColumnsList().forEach((c) -> System.err.println("By--Annotation: " + c.getName() + " ::   " + c.getValue()));
    }

    @UpdateHandlePoint
    public void handle1(CanalEntry.RowData rowData) {
        System.err.println("UpdateListenPoint");
        rowData.getAfterColumnsList().forEach((c) -> System.err.println("By--Annotation: " + c.getName() + " ::   " + c.getValue()));
    }

    @DeleteHandlePoint
    public void handle2(CanalEntry.EventType eventType) {
        System.err.println("DeleteListenPoint");
    }

    @HandlePoint(destination = "example", schema = "test_canal", table = {"user"}, eventType = CanalEntry.EventType.UPDATE)
    public void handle3(CanalEntry.EventType eventType, CanalEntry.RowData rowData) {
        System.err.println("UPDATE");
        rowData.getAfterColumnsList().forEach((c) -> System.err.println("By--Annotation: " + c.getName() + " ::   " + c.getValue()));
    }
}
